package com.modudf.util
{
	import com.modudf.common.Global;
	
	import flash.net.URLVariables;
	
	import mx.utils.URLUtil;
	
	public class ConnectParameter
	{
		
		private var _url:String;
		private var _params:URLVariables;
		private var _callback:Function;
		private var _isJson:Boolean;
		private var _failback:Function;
		private var _sessionTimeoutURL:String;

		public function ConnectParameter(o:Object){
			if (o == null){
				throw new Error("请输入Connect参数");
			}
			
			if (!o.hasOwnProperty("url")){
				throw new Error("Connect参数中缺少url");
			} else {
				this.url = o.url;
			}
			this.params = o.params;
			this.callback = o.callback;
			if (!o.hasOwnProperty("isJson")){
				o.isJson = true;
			}
			this.isJson = o.isJson;
			this.failback = o.failback;
		}
		
		public function set url(value:String):void{
			
			if (URLUtil.getProtocol(value)==""){
				this._url = Global.IP + value;
			} else {
				this._url = value;
			}
			
		}
		
		public function get url():String
		{
			//TODO: implement function
			return _url;
		}
		
		public function set params(value:URLVariables):void{
			this._params = value;
		}
		
		public function get params():URLVariables
		{
			//TODO: implement function
			return _params;
		}
		
		public function set callback(value:Function):void{
			this._callback = value;
		}
		
		public function get callback():Function
		{
			//TODO: implement function
			return _callback;
		}
		
		public function set isJson(value:Boolean):void{
			this._isJson = value;
		}
		
		public function get isJson():Boolean
		{
			//TODO: implement function
			return _isJson;
		}
		
		public function set failback(value:Function):void{
			this._failback = value;
		}
		
		public function get failback():Function
		{
			//TODO: implement function
			return _failback;
		}
		
		public function set sessionTimeoutURL(value:String):void{
			
			if (value){
				this._sessionTimeoutURL = value;
			}
			
			this._sessionTimeoutURL = Global.IP + Global.indexURL;
		}
		
		public function get sessionTimeoutURL():String{
			
			return _sessionTimeoutURL;
		}
	}
}